<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" placeholder="请输入0-100之间的整数" v-model="digit">
    <input type="button" value="猜一猜" @click="f()">
    <h1>结果：{{result}}</h1>

</div>

<script src="../js/vue.js"></script>
<script>
    let d = parseInt(Math.random()*101);
    let count = 0;
    let v = new Vue({
        el:"div",
        data:{
            digit:"",
            result:""
        },
        methods:{
            f(){
                console.log(d);
                console.log(v.digit)
                if(d > v.digit){
                    v.result = "太小了";
                    count++;
                }else if(d < v.digit){
                    v.result = "太大了";
                    count++
                }else{
                    v.result = "猜对了,你用了" + (count + 1) + "次";
                }

            }
        }
    })
</script>
</body>
</html>